package visiopuce.DAO;

import java.math.BigDecimal;
import java.util.List;

import org.hibernate.Query;

import visiopuce.HibernateUtil;
import visiopuce.objets.RenduFish;

public class RenduFishDAOImpl extends GenericDAOImpl<RenduFish, BigDecimal> implements RenduFishDAO {
	/** Constructeur priv� */
	private RenduFishDAOImpl() {
	}

	/** Instance unique non pr�initialis�e */
	private static RenduFishDAOImpl INSTANCE = null;

	/** Point d'acc�s pour l'instance unique du singleton */
	public static RenduFishDAO getInstance() {
		if (INSTANCE == null) {
			INSTANCE = new RenduFishDAOImpl();
		}
		return INSTANCE;
	}

	@Override
	public List<RenduFish> getResultatFishByIdPuce(Integer idPuce) {
		List<RenduFish> resultats = null;
		String sql = "SELECT r FROM RenduFish r WHERE r.puce.idPuce = :idPuce order by r.idRenduFish";
		Query query = HibernateUtil.getSession().createQuery(sql).setParameter("idPuce", idPuce);
		resultats = findMany(query);
		return resultats;
	}

	@Override
	public RenduFish getRenduFishByIdResultat(int idResultat) {
		RenduFish rendu = null;
		String sql = "SELECT r FROM RenduFish r WHERE r.resultat.idResultat = :idResultat";
		Query query = HibernateUtil.getSession().createQuery(sql).setParameter("idResultat", idResultat);
		rendu = findOne(query);
		return rendu;
	}



}